desc 'Release new pod version'
lane :release_pod do |options|
  target_repo    = options[:repo]
  target_project = options[:project]
  target_version = options[:version]
  spec_path = "#{target_project}.podspec"

  UI.message("👉 Start release lib #{target_project} new version #{target_version}")

  git_pull
  ensure_git_branch
  version_bump_podspec(path: spec_path, version_number: target_version)
  git_add(path: '.')
  git_commit(path: '.', message: 'release')
  push_to_git_remote
  if git_tag_exists(tag: target_version)
      UI.message("Tag #{target_version} already exists, then, delete it! 💥")
      remove_git_tag(tag: target_version)
  end
  add_git_tag(tag: target_version)
  push_git_tags
  pod_lib_lint(allow_warnings: true)
  if target_repo
    pod_push(path: spec_path, repo: target_repo, allow_warnings: true)
    UI.message("Release lib #{target_project} new version #{target_version} to repo #{target_repo} Successfully! 🎉 ")
  else
    pod_push(path: spec_path, repo: "YQPods", allow_warnings: true)
    UI.message("Release lib #{target_project} new version #{target_version} to CocoaPods/Specs Successfully! 🎉 ")
  end
end

lane :commit do |options|
  target_repo    = "YQPods"
  target_project = "XTLogin"
  target_version = options[:version]
  spec_path = "#{target_project}.podspec"
  UI.message("👉 Start release lib #{target_project} new version #{target_version}")
  git_pull
  ensure_git_branch
  version_bump_podspec(path: spec_path, version_number: target_version)
  git_add(path: '.')
  git_commit(path: '.', message: "release #{target_version}")
  push_to_git_remote
  if git_tag_exists(tag: target_version)
      UI.message("Tag #{target_version} already exists, then, delete it! 💥")
      remove_git_tag(tag: target_version)
  end
  add_git_tag(tag: target_version)
  push_git_tags
  pod_lib_lint(allow_warnings: true)
end
